package com.chanzany.visitor.case2;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

//数据结构类
public class Home {
    private List<Animal> nodeList = new ArrayList<>();
    public void add(Animal animal){
        nodeList.add(animal);
    }
    public void action(Person p){
        Iterator<Animal> iterator = nodeList.iterator();
        while (iterator.hasNext()){
            iterator.next().accept(p);
        }
    }
}
